home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Sleep Deprivation 1.0 Source / Sleep Deprivation ƒ / sd wipes ƒ / Spiral wipe.c < prev   
Encoding:
C/C++ Source or Header  |  1993-11-12  |  2.9 KB  |  112 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Spiral wipe.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Sleep Deprivation -- graphic effects on sleep
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define BOXSIZE 20
  32. #define CorrectTime 1
  33.  
  34. void SpiralGyra(GrafPtr, Pattern*);
  35.  
  36. /* Start in the topleft corner, facing downwards.  Copy until you hit (a) the
  37.    edge of the screen, or (b) bits you've already copied.  Then turn counter-
  38.    clockwise and do it again.  */
  39.    
  40. void SpiralGyra(GrafPtr thePtr, Pattern *thePattern)
  41. {
  42.     int            stop,sbottom,sleft,sright,iterrow,itercol,direction;
  43.     Rect        source;
  44.     Boolean        everyOther;
  45.     int            width,height;
  46.  
  47.     width=thePtr->portRect.right-thePtr->portRect.left;
  48.     height=thePtr->portRect.bottom-thePtr->portRect.top;
  49.     
  50.     everyOther=FALSE;
  51.     stop=0;
  52.     sbottom=height/BOXSIZE-(height%BOXSIZE ? 0 : 1);
  53.     sleft=0;
  54.     sright=width/BOXSIZE-(width%BOXSIZE ? 0 : 1);
  55.     direction=3;
  56.     iterrow=stop;
  57.     itercol=sleft;
  58.     while ((stop<=sbottom)&&(sleft<=sright))
  59.     {
  60.         StartTiming();
  61.         source.top=iterrow*BOXSIZE;         /* Yes, I know I should recode this */
  62.         source.bottom=source.top+BOXSIZE;   /* to take out multiplication. */
  63.         source.left=itercol*BOXSIZE;        /* If it matter that much to you, */
  64.         source.right=source.left+BOXSIZE;   /* you do it. */
  65.  
  66.         FillRect(&source, *thePattern);
  67.         
  68.         switch (direction)
  69.         {
  70.             case 0:  /* facing right */
  71.                 if (itercol==sright)
  72.                 {
  73.                     sbottom--;
  74.                     direction++;
  75.                     iterrow--;
  76.                 }
  77.                 else itercol++;
  78.                 break;
  79.             case 1:  /* facing up */
  80.                 if (iterrow==stop)   /* that reads "s top," not "stop" */
  81.                 {
  82.                     sright--;
  83.                     direction++;
  84.                     itercol--;
  85.                 }
  86.                 else iterrow--;
  87.                 break;
  88.             case 2:  /* facing left */
  89.                 if (itercol==sleft)
  90.                 {
  91.                     stop++;
  92.                     direction++;
  93.                     iterrow++;
  94.                 }
  95.                 else itercol--;
  96.                 break;
  97.             case 3:  /* facing down */
  98.                 if (iterrow==sbottom)
  99.                 {
  100.                     sleft++;
  101.                     direction=0;
  102.                     itercol++;
  103.                 }
  104.                 else iterrow++;
  105.                 break;
  106.         }
  107.         if (everyOther)
  108.             TimeCorrection(CorrectTime);
  109.         everyOther=!everyOther;
  110.     }
  111. }
  112.